<template>
	<view>
		<scroll-view scroll-y="true">
			<view class="top_box" :style="{height:`${250+statusBarHeight}px`}">
				<image class="bg" :style="{height:`${250+statusBarHeight}px`}" src="@/static/user/top-bgc.png" mode="">
				</image>
				<view class="top_info" :style="{marginTop:`${100+statusBarHeight*2}rpx`}">
					<view class="l">
						<view class="img">
							<image :src="$fun.imgUrl(userInfo.avatar)" @click="uploadPic" mode=""></image>
						</view>
						<view class="box" style="display: flex;flex-direction: column;">
							<view class="tel">
								{{userInfo.nickname}}
							</view>
							<view class="tel">
								{{userInfo.mobile}}
							</view>
						</view>

					</view>
					<!-- <view class="r">
						<image @click="jump('/pageA/set')" src="/static/newProject/set.png" mode=""></image>
					</view> -->
				</view>

			</view>
			<view :style="{height:`${150+statusBarHeight}px`}">

			</view>
			<view class="vip_box">
				<view class="vip-card-box">
					<view class="left">
						<image style="width: 78rpx;height: 78rpx;" src="@/static/user/vip.png" mode=""></image>
						<text>{{userInfo.levelname}}</text>
					</view>
					<!-- <view class="right">查看权益</view> -->
				</view>
				<!-- <image src="/static/arc.png" class="vip_bg" style="width: 100%; height: 18px;" mode=""></image> -->
			</view>
			<!-- <view class="tj-sction">
				<view class="tj-item" v-for="(item,index) in balanceList" :key='index' @click="onDetali(item)">
					<text class="num">{{item.money}}</text>
					<text>{{item.name}}</text>
				</view>
			</view> -->
			<!-- 订单 -->
			<view class="order-section">
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=1')" hover-class="common-hover"
					:hover-stay-time="50">
					<view class="">
						<image style="width: 50rpx;height: 50rpx;" src="@/static/user/obligation.png" mode=""></image>
					</view>
					<text>待付款</text>
				</view>
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=2')" hover-class="common-hover"
					:hover-stay-time="50">
					<view class="">
						<image style="width: 50rpx;height: 50rpx;" src="@/static/user/shipped.png" mode=""></image>
					</view>
					<text>待发货</text>
				</view>
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=3')" hover-class="common-hover"
					:hover-stay-time="50">
					<view class="">
						<image style="width: 50rpx;height: 50rpx;" src="@/static/user/received.png"></image>
					</view>
					<text>待收货</text>
				</view>
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=4')" hover-class="common-hover"
					:hover-stay-time="50">
					<view class="">
						<image style="width: 50rpx;height: 50rpx;" src="@/static/user/Completed.png" mode=""></image>
					</view>
					<text>已完成</text>
				</view>
				<view class="" style="width: 4rpx; height: 100rpx;background-color: #ff6754;"></view>
				<view class="order-item" @click="$fun.jump('/pageA/order/order?state=0')" hover-class="common-hover"
					:hover-stay-time="50">
					<view class="">
						<image style="width: 50rpx;height: 50rpx;" src="@/static/user/all.png" mode=""></image>
					</view>
					<text>全部订单</text>
				</view>
			</view>
			<view class="" style="margin: 24rpx 30rpx;" @tap="$fun.jump(`/pageA/shareErCode?qrtext=${qrtext}`)">
				<image style="width:100%;height: 154rpx;" src="@/static/user/invite.png"></image>
			</view>
			<view class="user_content1">
				<view class="usercenter" v-for="(item,index) in ywList" :key="index" @click="jump(item.url)">
					<view class="left">
						<image style="width: 42rpx;height: 44rpx;" :src="$fun.imgUrl(item.image)" mode=""></image>
						<view class="">{{item.name}}</view>
					</view>
					<image src="../../static/newProject/equipment/icon_r.png" mode=""></image>
				</view>
			</view>
			<!-- <u-cell-group :border="false">
				<u-cell @click="jump(item.url)" size="large" v-for="(item,index) in ywList" :key="index" icon="share"
					:title="item.name" :isLink="true" arrow-direction="arrow-right">
					<view class="" slot="icon">
						<image style="width: 40rpx;height: 40rpx;" :src="$fun.imgUrl(item.image)" mode=""></image>
					</view>
				</u-cell>
			</u-cell-group> -->
			<!-- <view class="user_content1">
				<view class="user_item" v-for="(item,index) in ywList" :key="index" @click="jump(item.url)">
					<image style="width: 42rpx;height: 44rpx;" :src="$fun.imgUrl(item.image)" mode=""></image>
					<view class="text">
						{{item.name}}
					</view>
				</view>
			</view> -->

			<!-- <view class="user_content1">

				<view class="user_item" v-for="(item,index) in ywList" :key="index" @click="jump(item.url)">
					<view class="">
						<image style="width: 42rpx;height: 44rpx;" :src="$fun.imgUrl(item.image)" mode=""></image>
						<view class="text">
							{{item.name}}
						</view>
					</view>
					<view class="">
						<u-icon name="photo"></u-icon>
					</view>
				</view>
			</view> -->
			<!-- 全网流量图 -->
			<!-- <block v-for="(item,index) in list" :key="index">
				<view class="wallet1">
					<view class="top_box1">
						<view class="l">
							<view class="text">
								{{item.t}}
							</view>
						</view>
						<view class="r">
							<view class="button">
							</view>
						</view>
					</view>
					<view class="wallet_box">
						<view class="wallet_item">
							<view>{{item.t1Num}}</view>
							<view>{{item.t1}} </view>
						</view>
						<view class="wallet_item" @click="$fun.jump(`/pageA/userLine?type=${item.key}&name=流量图查看`,0,0)">
							<image src="/static/k.jpg" mode=""></image>
							<view>流量图查看 </view>
						</view>
					</view>
				</view>
			</block> -->
			<!-- <view class="imgs_box">
				<image src="/static/newProject/imgs1.png" mode=""
					@click="jump(`/pageB/noticeList/noticeInfo?name=代理指南&type=17`)"></image>
				<image :src="$fun.imgUrl('webimage/imgs2.png')" mode="" @click="jump(`/pageA/share`)"></image>
			</view> -->
			<!-- <view class="user_content">
				<view class="user_item">
					<image src="/static/newProject/user/ioc-02.png" mode=""></image>
					<view class="text">
						我的订单
					</view>
				</view>
				<view class="user_item">
					<image src="/static/newProject/user/ioc-03.png" mode=""></image>
					<view class="text">
						我的激活码
					</view>
				</view>
				<view class="user_item" @click="jump(`/pages/index/noticeList/noticeList?type=0&name=公告`)">
					<image src="/static/newProject/user/ioc-04.png" mode=""></image>
					<view class="text">
						公告中心
					</view>
				</view>
			</view> -->

		</scroll-view>
		<!-- <view style="height: 170upx;">

		</view> -->
		<!-- #ifdef APP -->
		<!-- <TabBar :tabBarShow="3"></TabBar> -->
		<!-- #endif -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: {},
				balanceList: [],
				list: [],
				ywList: [],
				statusBarHeight: 0,
				qrtext: ''
			};
		},
		// 分享好友
		onShareAppMessage() {
			return {
				title: '鲸算网云',
				path: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		// 分享朋友圈
		onShareTimeline() {
			return {
				title: '鲸算网云',
				query: JSON.parse(uni.getStorageSync('gitH5Qrcode')),
			}
		},
		onLoad() {
			this.$fun.ajax.post('user/gitH5Qrcode', {}).then(res => {
				if (res.code == 1) {
					this.qrtext = res.data
					this.canvasQrPath = this.$fun.baseUrl() + res.data
				}
			})
		},
		async onShow() {
			// #ifdef APP
			// uni.hideTabBar()
			// #endif
			const phoneInfo = uni.getSystemInfoSync(); // 获取手机系统信息
			this.statusBarHeight = phoneInfo.statusBarHeight
			await this.$fun.ajax.post('user/index', {}).then(res => {
				if (res.code == 1) {
					this.userInfo = res.data
				}
			})
			await this.$fun.ajax.post('user/balance', {}).then(res => {
				if (res.code == 1) {
					this.balanceList = res.data
				}
			})
			await this.$fun.ajax.post('index/category', {}).then(res => {
				if (res.code == 1) {
					this.ywList = res.data
				}
			})
			await this.$fun.ajax.post('user/incomeKinfo', {}).then(res => {
				if (res.code == 1) {
					this.list = [

						{
							t: '全网流量查询',
							t1: '昨日累计流量',
							t1Num: res.data.totalflow,
							key: 1
						},
						{
							t: '个人流量查询',
							t1: '昨日流量贡献值',
							t1Num: res.data.flow,
							key: 2
						},
						{
							t: '火豆奖励查询',
							t1: '昨日火豆奖励值',
							t1Num: res.data.bean,
							key: 3
						},

					]
				}
			})
		},
		methods: {
			jump(url) {
				if (url.indexOf('http') != -1) {
					this.$fun.jump(`/pageA/webView/webView?url=${url}&name=网络测速`, 0, 0)
				} else {
					this.$fun.jump(url, 0, 0)
				}
			},
			uploadPic() {
				let _this = this
				uni.chooseImage({
					count: 1,
					success: res => {
						let tempFilePaths = res.tempFilePaths[0]
						uni.uploadFile({
							url: this.$baseUrl + '/api/common/upload', // 仅为示例，非真实的接口地址 
							filePath: tempFilePaths,
							name: 'file',
							header: {
								token: uni.getStorageSync('token')
							},
							success(res) {
								var res = JSON.parse(res.data)
								let userDate = {
									avatar: res.data.url,
								}
								_this.$fun.ajax.post('user/profile', {
									...userDate
								}).then(res1 => {
									if (res.code == 1) {
										_this.userInfo.avatar = res.data.fullurl

									}
								})
							},
						})
					}
				})
			},
			onDetali(item) {
				this.$fun.jump('/pageA/wallet/wallet')
			}
		}
	}
</script>

<style lang="scss">
	.top_box {
		position: absolute;
		top: 0;
		width: 100%;
		height: 251rpx;
		box-sizing: border-box;

		image.bg {
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			z-index: -100;
		}

		.top_info {
			margin-top: 46rpx;
			padding: 0 30rpx;
			box-sizing: border-box;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;

			.l {
				display: flex;
				align-items: center;

				.img {
					width: 120rpx;
					height: 120rpx;
					background: #EEEEEE;
					border-radius: 50%;
					display: flex;
					justify-content: center;
					align-items: center;

					image {
						width: 79rpx;
						height: 85rpx;
					}
				}

				.tel {
					margin-left: 17rpx;
					font-size: 30rpx;
					font-family: Microsoft YaHei;
					font-weight: bold;
					color: #F6F6F6;
				}
			}

			.r {
				image {
					width: 45rpx;
					height: 42rpx;
				}
			}

			.wallet {
				width: calc(100% - 60rpx);
				height: 240rpx;
				background: #FFFFFF;
				box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
				border-radius: 20rpx;

				.top_box1 {
					display: flex;
					padding: 10rpx 30rpx;
					justify-content: space-between;
					align-items: center;

					.l {
						display: flex;

						.text {
							font-size: 30rpx;
							font-family: Microsoft YaHei;
							color: #333333;
						}

						image {
							margin-left: 10rpx;
							width: 24rpx;
							height: 18rpx;
						}
					}

					.r {
						display: flex;

						.button {
							padding: 12rpx 30rpx;
							background: #FFFFFF;
							// border: 2rpx solid #0066FF;
							border-radius: 25rpx;
							text-align: center;
							font-size: 22rpx;
							font-family: Microsoft YaHei;
							color: #0066FF;
						}
					}

				}

				.wallet_box {
					width: 100%;
					display: flex;
					justify-content: space-between;
					padding: 30rpx;
					padding-top: 0;

					.wallet_item {
						width: 50%;

						view:nth-child(1) {
							font-size: 30rpx;
							font-family: Microsoft YaHei;
							font-weight: bold;
							color: #333333;
						}

						view:nth-child(2) {
							margin-top: 10rpx;
							font-size: 30rpx;
							font-family: Microsoft YaHei;
							font-weight: bold;
							color: #333333;

						}

					}
				}

			}

			.ab {
				position: absolute;
				left: 30rpx;
				bottom: -100rpx;
			}
		}
	}

	.wallet1 {
		width: calc(100% - 60rpx);
		height: 200rpx;
		margin: 20rpx 30rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;

		.top_box1 {
			display: flex;
			padding: 20rpx 30rpx;
			justify-content: space-between;
			align-items: center;

			.l {
				display: flex;

				.text {
					font-size: 28rpx;
					font-family: Microsoft YaHei;

					font-weight: bold;
					color: #333333;
				}

				image {
					margin-left: 10rpx;
					width: 24rpx;
					height: 18rpx;
				}
			}

			.r {
				display: flex;

				.button {
					padding: 12rpx 30rpx;
					background: #FFFFFF;
					// border: 2rpx solid #0066FF;
					border-radius: 25rpx;
					text-align: center;
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #0066FF;
				}
			}

		}

		.wallet_box {
			width: 100%;
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 30rpx;
			padding-bottom: 15rpx;
			padding-top: 0;

			.wallet_item {
				width: 50%;
				text-align: center;

				view:nth-child(1) {
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #333333;
				}

				view:nth-child(2) {
					margin-top: 10rpx;
					font-size: 28rpx;
					font-family: Microsoft YaHei;
					color: #333333;

				}

				image {
					width: 50rpx;
					height: 50rpx;
				}
			}
		}

	}

	.imgs_box {
		display: flex;
		justify-content: space-between;
		padding: 20rpx 30rpx;

		image {
			width: 330rpx;
			height: 160rpx;
			box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(0, 0, 0, 0.1);
			border-radius: 10rpx;
		}
	}

	.user_content {
		margin: 0 30rpx;
		padding: 20rpx 0;
		display: flex;
		justify-content: center;
		background: #FFFFFF;
		box-shadow: 0px 0px 20rpx 0px rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;

		.user_item {
			width: 20%;
			text-align: center;
			margin-right: 30rpx;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			.text {
				color: #333333;
				font-size: 24rpx;
			}
		}
	}

	.user_content1 {
		width: 690rpx;
		// height: 638rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		margin: 0 auto;
		padding: 28rpx 40rpx;
		box-sizing: border-box;
		font-weight: 400;
		font-size: 24rpx;
		color: #232323;

		.usercenter {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 72rpx;
		}

		.left {
			display: flex;
			align-items: center;

			image {
				width: 52rpx;
				height: 52rpx;
				margin-right: 20rpx;
			}
		}

		image {
			width: 12rpx;
			height: 24rpx;
		}

		.user_item {
			width: 25%;
			text-align: center;
			margin-bottom: 20rpx;

			image {
				width: 80rpx;
				height: 80rpx;
			}

			.text {
				color: #333333;
				font-size: 28rpx;
			}
		}
	}

	.tj-sction {
		display: flex;
		align-items: center;
		justify-content: space-around;
		background: #FFFFFF;
		// box-shadow: 0px 0px 11px 0px rgb(0 0 0 / 10%);
		border-radius: 11px;
		margin: 0 16px;

		// @extend %section;
		.tj-item {
			// @extend %flex-center;
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			height: 140upx;
			font-size: $font-sm;
			color: #75787d;
		}

		text {
			color: #75787d;
			font-size: 24rpx;
		}

		.num {
			font-size: 30rpx;
			color: #303133;
			margin-bottom: 8rpx;
		}
	}

	.order-section {
		display: flex;
		align-items: center;
		justify-content: space-around;
		background: #FFFFFF;
		// box-shadow: 0px 0px 11px 0px rgb(0 0 0 / 10%);
		border-radius: 0 0 10rpx 10rpx;
		margin: 0 16px;
		padding: 28upx 0;
		// margin-top: 20upx;

		.order-item {
			display: flex;
			align-items: center;
			justify-content: center;
			flex-direction: column;
			width: 120upx;
			height: 120upx;
			border-radius: 10upx;
			font-size: $font-sm;
			color: $font-color-dark;
		}

		.yticon {
			font-size: 48upx;
			margin-bottom: 18upx;
			color: $base-color;
		}

		.icon-shouhoutuikuan {
			font-size: 44upx;
		}
	}

	.vip_box {
		position: relative;

		.vip-card-box {
			display: flex;
			justify-content: space-between;
			align-items: center;
			color: #f7d680;
			height: 100rpx;
			background-color: #000;
			margin: 0 30rpx;
			padding: 20rpx;
			border-top-left-radius: 20rpx;
			border-top-right-radius: 20rpx;

			.left {
				display: flex;
				align-items: center;
			}

			.right {
				padding: 10rpx;
				background-color: #fd8750;
				border-radius: 30rpx;
				font-size: 24rpx;
			}

		}

		.vip_bg {
			position: absolute;
			left: 0px;
			bottom: 0;
		}
	}
</style>